/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Database;

import Model.Surat;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;

public class UserSuratTable extends AbstractTableModel {

    private String columns[] = {"No Surat", "Perihal", "Asal Surat", "Penerima Surat", "Id Penerima", "Letak Surat", 
        "Petugas Terima", "Tanggal Terima", "Terima"};
    private ArrayList<Surat> datasurat;

    public UserSuratTable() {
    }

    public UserSuratTable(ArrayList<Surat> datasurat) {
        this.datasurat = datasurat;
    }

    @Override
    public int getRowCount() {
        return getDataSurat().size();
    }

    public String getColumns(int col) {
        return columns[col];
    }

    @Override
    public int getColumnCount() {
        return columns.length;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Surat surat = getDataSurat().get(rowIndex);
        if (columnIndex == 0) {
            return surat.getNomor_surat();
        } else if (columnIndex == 1){
            return surat.getPerihal();
        } else if (columnIndex == 2){
            return surat.getAsal_surat();
        } else if (columnIndex == 3){
            return surat.getPenerima_surat();
        } else if (columnIndex == 4){
            return surat.getId_penerima();
        } else if (columnIndex == 5){
            return surat.getLetak_surat();
        } else if (columnIndex == 6){
            return surat.getPetugas_penerima();
        } else if (columnIndex == 7){
            return surat.getTanggal_terima();
        } else {
            return surat.getTerima();
        }
    }

    public ArrayList<Surat> getDataSurat() {
        return datasurat;
    }

    public void setDataSurat(ArrayList<Surat> datasurat) {
        this.datasurat = datasurat;
    }
}
